package com.sias.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hy.corecode.idgen.WFGIdGenerator;
import com.sias.entity.dto.CourseInfoDto;
import com.sias.entity.pojo.Course;
import com.sias.service.CourseService;
import com.sias.mapper.CourseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author chf
* @description 针对表【course】的数据库操作Service实现
* @createDate 2024-07-09 22:53:53
*/
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course>
    implements CourseService{

    @Autowired
    private WFGIdGenerator wFGIdGenerator;

    @Override
    public String saveCourseInfo(CourseInfoDto courseInfoDto) {
        Course course = new Course();
        BeanUtil.copyProperties(courseInfoDto,course);
        course.setId(String.valueOf(wFGIdGenerator.next()));
        course.setCreateTime(new Date());
        course.setUpdateTime(new Date());
        course.setIsDelete("0");
        course.setParentId("0");
        int i = baseMapper.insert(course);
        if (i>0){
            return course.getId();
        }
        return null;
    }
}




